<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@include file="/include/common/gridbackhead.jsp"%>
<%!
private class PageAction extends BaseAction{
	ResultSet rs = null;
	StringBuilderEx sql = null;
	
	//准备action的环境变量 每次请次都会执行此方法 可在此方法中初如化一些变量
	protected void prepareActionEnv() throws Exception{
		sql = new StringBuilderEx();
	}
	
	//加載頁面默認數據
	protected boolean onLoadDefault() throws Exception{
		onSearchRetrieveResult();
		return true ;
	}
	
	// 取出查询結果
	protected void onSearchRetrieveResult() throws Exception{
		if(!form.isNullOrEmpty("pan_subpro_menusn")){
			sql.Reset();
			sql.Append("\r\n declare @menusn int ,@hrnums nvarchar(4000),@ips nvarchar(4000),@hr003tsns nvarchar(4000) ");
			sql.Append("\r\n set @menusn = %1$s",form.gpsv("pan_subpro_menusn"));
			sql.Append("\r\n select top 0 convert(nvarchar(20),'') as hrnum,convert(nvarchar(20),'') as chname into #aa ");
			
			sql.Append("\r\n select @hrnums = hrnums,@ips = ips,@hr003tsns = hr003tsns from pan.dbo.PAN_SUBPRO_MENU where sn = @menusn");
			sql.Append("\r\n insert into #aa select a.hrNum,a.chName from hr..hr005 a,pan..f_split(@hrnums,',') b where a.hrNum = b.titles");
			sql.Append("\r\n insert into #aa select c.hrnum,c.chname from pan..PAN_SUBPRO_APPIP a,pan..f_split(@hr003tsns,',') b,pan..PAN_SUBPRO_APPHRNUM c where a.hr003tsn = b.titles and a.sn = c.applySn");
			sql.Append("\r\n insert into #aa select c.hrnum,c.chname from pan..PAN_SUBPRO_APPIP a,pan..f_split(@ips,',') b,pan..PAN_SUBPRO_APPHRNUM c where a.ip = b.titles and a.sn = c.applySn");
			sql.Append("\r\n select distinct hrnum,chname from #aa ");
			sql.Append("\r\n drop table #aa ");
			rs = utils.executeQuery("info5",sql.toString());
			ret.SetSearchResult(rs);
		}
	}

	//取出查詢語句
	protected String onSearchGetSql() throws Exception{
		StringBuilderEx whr =  new StringBuilderEx("1=1");
		return whr.toString();
	}

}
%>
<%@include file="/include/common/gridbackend.jsp"%>